package refect.example;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

/**
 * 框架类
 **/
public class RefectTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        ClassLoader loader = RefectTest.class.getClassLoader();
        InputStream inputStream = loader.getResourceAsStream("refect/pro.properties");

        Properties properties = new Properties();
        properties.load(inputStream);

        String className = properties.getProperty("className");
        String methodName = properties.getProperty("methodName");

        Class cls = Class.forName(className);
        Method method = cls.getMethod(methodName, String.class);

        Object obj = cls.newInstance();
        method.invoke(obj, "rice");

    }
}
